import Vue from 'vue'
import Router from 'vue-router'
import logIn from '@/pages/logIn.page'
import Home from '@/pages/Home.page'
import product from './product'
import trends from '@/router/trends'
import discrimination from './discrimination'
import baike from './baike'

Vue.use(Router)

const router = new Router({
  routes: [{
      path: '/',
      component: logIn
    },
    product,
    trends,
    baike,
    discrimination
  ]
})

router.beforeEach((to, from, next) => {
  let access = Vue.prototype.access
  if (to.path === '/') {
    next()
  } else {
    if (!access) {
      next('/')
    } else {
      next();
    }
  }
})



export default router;
